<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../../vue文件/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="number" v-model.number='num1'>
        <select v-model='opt'>
            <option value="+">+</option>
            <option value="-">-</option>
            <option value="*">*</option>
            <option value="/">/</option>
        </select>
        <input type="number" v-model.number='num2' @keyup.enter='result'>
        <button value="=" @click='result'>=</button>
        <input type="number" v-model='ret'> 
    </div>
</body>
<script>
    let vm = new Vue({
        el:'#app',
        data:{
            num1:0,
            num2:0,
            opt:'+',
            ret:0
        },
        methods:{
            result(){
                this.ret = (eval(Number(this.num1)+this.opt+Number(this.num2))).toFixed(2)
                // switch(this.opt){
                //     case "+":
                //          this.ret = Number(this.num1)+Number(this.num2)
                //         break;
                //     case "-":
                //          this.ret = Number(this.num1)-Number(this.num2)
                //         break;
                //     case "*":
                //          this.ret = Number(this.num1)*Number(this.num2)
                //         break;
                //     case "/":
                //          this.ret = Number(this.num1)/Number(this.num2)
                //         break;
                    
                // }
                
            }
        }
    })
</script>
</html>